﻿using System;
using System.Collections.Generic;
using System.Text;
using Chaliy.DbPro.Generators.TextAuthoring.Configuration;
using System.Collections;

namespace Chaliy.DbPro.Generators.TextAuthoring
{
	public class ListTermAccessor : ITermAccessor
	{
		#region Fields

		private readonly IList<TermConfiguration> termsSource;		

		#endregion

		#region Constructors

		public ListTermAccessor(IList<TermConfiguration> termsSource)
		{
			if (termsSource == null)
			{
				throw new ArgumentNullException("termsSource");
			}
			this.termsSource = termsSource;
		}

		#endregion

		#region Properties

		protected IList<TermConfiguration> TermsSource
		{
			get 
			{
				return this.termsSource; 
			}
		} 

		#endregion

		#region ITermAccessor Members

		public int Count
		{
			get 
			{ 
				return this.TermsSource.Count; 
			}
		}

		public string this[int index]
		{
			get
			{
				return this.TermsSource[index].Value;
			}
		}

		#endregion

		#region IEnumerable<TermConfiguration> Members

		public IEnumerator<TermConfiguration> GetEnumerator()
		{
			return this.TermsSource.GetEnumerator();
		}

		#endregion

		#region IEnumerable Members

		IEnumerator IEnumerable.GetEnumerator()
		{
			return this.GetEnumerator();
		}

		#endregion	
	}
}
